package com.mk.admin.controller;

import com.mk.admin.model.ResultDto;
import com.mk.admin.model.query.DictionaryQuery;
import com.mk.admin.model.query.ListQuery;
import com.mk.admin.model.vo.DictionaryVo;
import com.mk.admin.service.DictionaryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/a/adm/dictionary")
@Api(tags = "数据字典")
public class DictionaryController {
    @Autowired
    private DictionaryService dictionaryService;

    @PostMapping("/select")
    public ResultDto select(@RequestBody DictionaryQuery query) {
        return dictionaryService.select(query);
    }

    @PostMapping("/selectByCodes")
    @ApiOperation(value = "查询多个code的数据", notes = "直接多个code的值的集合 {\n" +
            "\"list\": [\"beInHospitalNeedKnow\",\n" +
            "\"inHospitalNeedKnow\",\n" +
            "\"leaveHospitalNeedKnow\"]\n" +
            "}")
    public ResultDto selectByCodes(@RequestBody ListQuery query) {
        return dictionaryService.selectByCodes(query);
    }

    @PostMapping("/add")
    public ResultDto add(@RequestBody DictionaryVo vo) {
        return dictionaryService.add(vo);
    }

    @PostMapping("/update")
    public ResultDto update(@RequestBody DictionaryVo vo) {
        return dictionaryService.update(vo);
    }

    @PostMapping("/delete")
    public ResultDto delete(@RequestBody DictionaryVo vo) {
        return dictionaryService.delete(vo.getId());
    }

    @PostMapping("/status")
    public ResultDto status(@RequestBody DictionaryVo vo) {
        return dictionaryService.status(vo.getId());
    }
}
